<?php
// 判断用户是否是管理员
session_start();
if($_SESSION['userinfo']["isadmin"]!=1) die("<a href='#' onclick='window.history.back()'>权限不足</a>");

$tid = $_GET["tid"];
// 创建数据库连接
$db = mysqli_connect("localhost","root","123456","bbs");
$sql = "select * from type where tid=? ";
$pre = $db->prepare($sql);  // 预编译

$pre->bind_param("i",$tid);
// 获取结果集，参数传存结果列的变量
$pre->bind_result($tid,$type_code,$type_name);
// 执行预编译sql
$pre->execute();
$userType = array();
if($pre->fetch()){
    $userType = array();
    $userType['tid'] = $tid;
    $userType['type_code'] = $type_code;
    $userType['type_name'] = $type_name;
}
?>

<form action="doUpdateType.php" method="post" >
    <label>
        类型代码：
        <input name="type_code" type="text" value="<?php echo $userType['type_code'] ?>">
    </label> <br>
    <label>
        类型名称：
        <input name="type_name" type="text" value="<?php echo $userType['type_name'] ?>">
    </label> <br>
    <input type="hidden" name="tid" value="<?php echo $userType['tid'] ?>">
    <input type="submit" value="修改类型">
    <button type="button" onclick="window.location.href='admin.php'" >返回</button>
</form>
